.TH std::chrono::weekday_last::weekday_last 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::chrono::weekday_last::weekday_last \- std::chrono::weekday_last::weekday_last

.SH Synopsis
   constexpr explicit weekday_last( const std::chrono::weekday& wd )      \fI(since C++20)\fP
   noexcept;

   Constructs a weekday_last object storing the weekday wd.

.SH Notes

   A more convenient way to construct a weekday_last is with weekday's operator[],
   i.e., wd[std::chrono::last].

.SH Example


// Run this code

 #include <chrono>
 #include <iostream>
 using namespace std::chrono;

 int main()
 {
     const year_month_day ymd{floor<days>(system_clock::now())};
     const weekday_last wdl{Sunday[last]}; // A last Sunday of a month
     const year_month_day last_sun{ymd.year() / ymd.month() / wdl};

     std::cout << "The last Sunday of current month falls on "
               << (int)last_sun.year() << '/'
               << (unsigned)last_sun.month() << '/'
               << (unsigned)last_sun.day() << '\\n';
 }

.SH Possible output:

 The last Sunday of current month falls on 2021/9/26
